
package com.scs.application.modules.base.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.scs.application.core.model.CommonResult;
import com.scs.application.core.service.IBaseService;
import com.scs.application.modules.base.dto.HospitalMaterialDTO;
import com.scs.application.modules.base.entity.HospitalMaterial;
import com.scs.application.modules.base.entity.Material;
import com.scs.application.modules.base.request.HospitalMaterialQueryRequest;
import com.scs.application.modules.base.request.HospitalMaterialRequest;
import com.scs.application.modules.base.vo.HospitalMaterialVO;
import com.scs.application.modules.thirdparty.erp.request.MaterialRequest;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * HospitalMaterial service 接口
 */
public interface HospitalMaterialService extends IBaseService<HospitalMaterial> {

    List<HospitalMaterial> list(HospitalMaterialQueryRequest request);


    IPage<HospitalMaterial> page(HospitalMaterialQueryRequest request);

    /**
     * 院方接口 商品查询
     *
     * @param request 商品院内编码materialCode 或者 不传
     * @return 对应商品 或者 全部商品
     */
    List<HospitalMaterialVO> listVO(HospitalMaterialRequest request);

    CommonResult listForErp(MaterialRequest request);

    /**
     * 接收院方接口添加或修改医院商品信息
     *
     * @param dtos
     */
    @Transactional(rollbackFor = Exception.class)
    List<String> batchSave(List<HospitalMaterialDTO> dtos);

    /**
     * 将医院商品状态设为正常
     *
     * @param id
     */
    @Transactional(rollbackFor = Exception.class)
    void active(String id);

    /**
     * 将医院商品状态设为停用
     *
     * @param id
     */
    @Transactional(rollbackFor = Exception.class)
    void deactive(String id);

    /**
     * 关键字搜索医院商品
     *
     * @param request
     * @return
     */
    IPage<HospitalMaterial> pageByKeyword(HospitalMaterialQueryRequest request);

    /**
     * 供应商下的品规数量
     *
     * @return
     */
    int countForSupplier(HospitalMaterialQueryRequest request);

    /**
     * 全部启用
     */
    @Transactional(rollbackFor = Exception.class)
    void allActive();

    /**
     * 全部停用
     */
    @Transactional(rollbackFor = Exception.class)
    void allInactive();

    /**
     * 根据医院id获取医院商品
     *
     * @param hospitalId
     * @return
     */
    List<HospitalMaterial> listByHospital(String hospitalId, String supplierId);

    /**
     * 批量新增
     *
     * @param hospitalId
     */
    @Transactional(rollbackFor = Exception.class)
    void batchInsertFromTodayCreateMaterial(String hospitalId);

    HospitalMaterial getOneHospitalMaterial(HospitalMaterialRequest request);

    // 商品变更后，修改已供货商品
    void updateFromMaterialChange(Material entity);
}
